﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Common;
using System.Linq;
using System.Text;

using ZhimeiSoft.CharmManager.DOL;
using ZhimeiSoft.CharmManager.Server.DAL.Interface;
using ZhimeiSoft.Framework.Server.Base;

namespace ZhimeiSoft.CharmManager.Server.DAL
{
    public class PayTypeDAL : BaseDal, IPayTypeDAL
    {
        #region IPayTypeDAL Members

        public DataSet GetPayType(string sFilter)
        {
            string strSQL = PayTypeDAL_Const.SQL_SLECT_PAYTYPE;
            if (!string.IsNullOrEmpty(sFilter))
                strSQL = strSQL + " WHERE " + sFilter;
            DbCommand cmd = DB.GetSqlStringCommand(strSQL);
            return DB.ExecuteDataSet(cmd);
        }

        public void InsertPayType(DBEntityPayType entity)
        {
            string strSQL = PayTypeDAL_Const.SQL_INSERT_PAYTYPE;
            DbCommand cmd = DB.GetSqlStringCommand(strSQL);
            DB.AddInParameter(cmd, DBEntityPayType.FieldName.PNAME, DbType.String, entity.PName);
            DB.AddInParameter(cmd, DBEntityPayType.FieldName.PMEMO, DbType.String, entity.PMemo);
            DB.ExecuteNonQuery(cmd);
        }

        public void UpdatePayType(DBEntityPayType entity)
        {
            string strSQL = PayTypeDAL_Const.SQL_UPDATE_PAYTYPE;
            DbCommand cmd = DB.GetSqlStringCommand(strSQL);
            DB.AddInParameter(cmd, DBEntityPayType.FieldName.PAYTYPEID, DbType.Int32, entity.PayTypeID);
            DB.AddInParameter(cmd, DBEntityPayType.FieldName.PNAME, DbType.String, entity.PName);
            DB.AddInParameter(cmd, DBEntityPayType.FieldName.PMEMO, DbType.String, entity.PMemo);
            DB.ExecuteNonQuery(cmd);
        }

        public void DeletePayType(int paytype_id)
        {
            string strSQL = PayTypeDAL_Const.SQL_DELETE_PAYTYPE;
            DbCommand cmd = DB.GetSqlStringCommand(strSQL);
            DB.AddInParameter(cmd, DBEntityPayType.FieldName.PAYTYPEID, DbType.Int32, paytype_id);
            DB.ExecuteNonQuery(cmd);
        }

        #endregion
    }
}
